# coding:utf-8
def count_words(filename):
    """计算一个文本大约包含多少单词"""
    try:
        with open(filename,encoding='utf-8') as f:
            contents = f.read()
    except FileNotFoundError:
        #print(f"Sorry,the file {filename} doesn't exit")
        pass
    else:
        words = contents.split()
        num_words=len(words)
        print(f"The file {filename} has about {num_words} words.")


filenames = ["alice.txt","little_women.txt","soddhartha.txt","moby_dick.txt"]
for filename in filenames:
    count_words(filename)